//
//  channelsGroup.m
//  NewsReader
//
//  Created by lang langhonglin on 10-8-12.
//  Copyright 2010 hgzp. All rights reserved.
//

#import "channelsGroup.h"
#import "channels.h"


@implementation channelsGroup

@synthesize xmlParser,appsetArray;

- (BOOL)parserChannelsXML:(NSString *)urlXML {
	
	//重新加載xmlParser
	if( xmlParser )
	{
		[xmlParser release];
	}
	if( appsetArray )
	{
		[appsetArray release];
	}
	NSLog(@"parserChannel");
	appsetArray = [[NSMutableArray alloc] initWithCapacity:50]; 
	NSURL *url= [NSURL URLWithString:urlXML];
	xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
	[xmlParser setDelegate: self];
	[xmlParser setShouldResolveExternalEntities: YES];
	[xmlParser parse];
	return YES;
	
	
}

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
   attributes: (NSDictionary *)attributeDict
{
	
	NSLog(@"didstart");

	if (qName) {
        elementName = qName;
    }
    if ([elementName isEqualToString:@"channels"]) {
        // 输出属性值
		channels*  channel = [[channels alloc] initWithName:[attributeDict objectForKey:@"name"] channelUrl:[attributeDict objectForKey:@"url"] channelLeftImage:[attributeDict objectForKey:@"leftimage"]];
		[appsetArray addObject:channel];
		
    }
   	
	
}


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
	
	/*if( recordResults )
	 {
	 [soapResults appendString: string];
	 }*/
	
	
}


-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
	
	if( [elementName isEqualToString:@"RegisterNewUserResult"])
	{
		;
	}
	
}


- (void)parserDidStartDocument:(NSXMLParser *)parser{
}


- (void)parserDidEndDocument:(NSXMLParser *)parser{
	
}


- (void)dealloc 
{
	[xmlParser release];
	[appsetArray release];
	[super dealloc];
}



@end
